#pragma once

#include "Framework/ApplicationSubsystem.h"
#include "Containers/Delegate.h"
#include "Containers/Format.h"
#include "Console.m.h"

//depreacted, use new console
RCLASS()
class WHENGINE_API RConsole : public RApplicationSubsystem
{
    ROBJECT
public:
    void Initialize() override;
    void Deinitialize() override;

    RConsole();


    static RConsole * Get();

    RFUNCTION()
    static void PrintLine(const CString& InMessage);
    TMultiCastDelegate<const CString&> OnPrint;
    static void PrintString(const CString& InMessage,bool EndLine=true);

    RFUNCTION()
    static void ErrorLine(const CString& InMessage);
    static void ErrorString(const CString& InMessage,bool EndLine=true);

};

namespace WH
{
    template< typename... Args>
    static void PrintLine(const CString& Format,Args... LeftArgs)
    {
        RConsole::PrintString(WH::Format(Format, LeftArgs...),true);
    }

    template< typename... Args>
    static void Print(const CString& Format,Args... LeftArgs)
    {
        RConsole::PrintString(WH::Format(Format, LeftArgs...),false);
    }

    template< typename... Args>
    static void ErrorLine(const CString& Format,Args... LeftArgs)
    {
        RConsole::ErrorString(WH::Format(Format, LeftArgs...),true);
    }

    template< typename... Args>
    static void Error(const CString& Format,Args... LeftArgs)
    {
        RConsole::ErrorString(WH::Format(Format, LeftArgs...),false);
    }
    
}